import { request } from '@/apis';
import { addPrefix } from '@/utils/helper';

export * from './pollution-discharge-permits';
export * from './industry-comparison';
export * from './insurance';

const prefixUrl = '/ep-query';

const Api = {
  /** 工商信息 */
  companyBaseInfo: '/f9/getCompanyBasicInfo',
  /** 企业动态 */
  enterpriseDynamics: '/event/v2/companyEvent',
  /** 环境监督 */
  getF9Data: '/v2/hbSubject/getHbSubjectF9',
  /** esg 公告 */
  companyEsg: '/companyEsg',
  /** esg公共tab信息 */
  classificationCode2: '/event/classificationCode2',
  /** 管理体系认证 */
  getCertificationF9: '/getCertificationF9',
  /** esg争议事件 */
  getEsgEventF9: '/getEsgEventF9',
  /** esg争议事件code */
  esgEventCodes: '/v2/esgEvent/statistics',
  /** esg争议事件风险等级 */
  esgEventRiskLevel: '/screen/esgEventRiskLevel',
  /** 环保处罚 */
  getPunishData: '/getPenaltyF9',
  /** 碳减排支持工具 */
  getCarbonReductionF9: '/getCarbonReductionF9',
  /** 绿色信贷 */
  greenCreditF9: '/greenCreditF9',
  /** 是否为上市公司 */
  isListedCompany: '/isListedCompany',
  /** 公司治理 */
  getSgPerformance: '/getSgPerformance',
  /** 环境绩效 */
  environmentalPerformanceF9: '/environmentalPerformanceF9',
  /** 绿色债券 */
  getGreenBondF9: '/getGreenBondF9',
  /** 绿色债券项目 */
  getGreenProjectF9: '/getGreenProjectF9',
  /** 排污监测数据列表 */
  monitoring: '/monitoring',
  /** 排污监测监测项目筛选 */
  getMonitorItem: '/screen/supervisoryMonitorItem',
  /** 排污监测监测点筛选 */
  getMonitorStation: '/screen/supervisoryMonitorStation',
  /** 未开展监测数据列表 */
  noSelfMonitorF9: '/noSelfMonitorF9',
  /** 不监测类型筛选 */
  noSelfMonitorType: '/screen/noSelfMonitorType',
  /** 不监测名称筛选 */
  noSelfMonitorItem: '/screen/noSelfMonitorItem',
  /** 治污设施异常列表接口 */
  abnormalFacilities: '/v2/pollution/abnormalFacilities',
  /** 治污设施异常许可证筛选项接口 */
  abnormalFacilitiesNoFilter: '/v2/screen/abnormalFacilitiesNoFilter',
  /** 治污设施异常污染因子筛选项接口 */
  abnormalFacilitiesPollutionFilter: '/v2/screen/abnormalFacilitiesPollutionFilter',
  /** 超标排放取值类型获取 */
  getSupervisoryMonitorType: '/v2/getSupervisoryMonitorType',
  /** 企业动态分类 */
  getEnterpriseDynamicsClassify: '/event/v2/code2Statistics'
};

addPrefix(Api, prefixUrl);

export interface DynamicsProps extends PageProps {
  /** 公司 id */
  id: string;
  /** 一级code，10-环境|20-社会责任|30-公司治理|40-ESG */
  codeLevel1: number | string;
  /** 二级code */
  codeLevel2?: string;
  /** 三级code */
  codeLevel3?: string;
  startDate?: string;
  endDate?: string;
  order?: OrderType;
}

/** 企业工商信息 */
export const getCompanyBasicInfo = (id: string) => request.get({ url: Api.companyBaseInfo, params: { id } });

/** 企业动态数据 */
export const getEnterpriseDynamicsData = (params: DynamicsProps) =>
  request.get({
    url: Api.enterpriseDynamics,
    params
  });

/** 企业动态分类数据 */
export const getEnterpriseDynamicsClassify = (params) =>
  request.get({
    url: Api.getEnterpriseDynamicsClassify,
    params
  });

export enum HbSubjectEnum {
  /** 环境黑名单 */
  BLACKLIST = 'blacklist',
  /** 企业环境信用评级 */
  ENVIRONMENTCREDITRATE = 'environmentCreditRate',
  /** 碳排放市场参与企业 */
  CARBONEMISSION = 'carbonEmission',
  /** 重点排污 */
  KEYSEWAGE = 'keySewage',
  /** 清洁生产审核 */
  CLEANERPRODUCTION = 'cleanerProduction',
  /** 重点用能单位 */
  ENERGYCONSUMPTION = 'energyConsumption',
  /** 绿色工厂 */
  GREENFACTORY = 'greenFactory',
  /** 绿色企业 */
  GREENCOMPANY = 'greenCompany',
  /** 绿色矿山 */
  GREENMINE = 'greenMine',
  /** 绿色供应链管理企业 */
  GREENSUPPLYCHAIN = 'greenSupplyChain',
  /** 绿色设计产品企业 */
  GREENDESIGN = 'greenDesign',
  /** 工业产品绿色设计示范企业 */
  INDUSTRIALPRODUCTSGREENDESIGN = 'industrialProductsGreenDesign'
}

export interface EnvironmentalSupervisionProps extends PageProps {
  /** 公司 id */
  companyId?: string;
  id?: string;
  /** 环保专题类型 */
  hbSubjectType?: HbSubjectEnum;
  /** 排序 noticeDate:desc,tagYear:desc */
  sortRule?: string;
  /** row.type === '1' ? '许可证撤销' : row.type === '2' ? '许可证注销' : row.type === '3' ? '许可证遗失' */
  type?: '' | 1 | 2 | 3;
}

/** 环境监督 */
export const getF9Data = (params: EnvironmentalSupervisionProps) =>
  request.get({
    url: Api.getF9Data,
    params
  });

export interface EsgAnnouncementProps extends PageProps {
  /** 公司 id */
  id?: string;
  /** 地区频道内分类代码，100000-争议事件|200000-一般事件|300000-信息披露|400000-环境处罚 */
  classificationCode1?: number;
  /** tab 信息 code */
  classificationCode2?: string;
  /** 排序 */
  sort?: string;
}

/** esg 公告 */
export const getCompanyEsgData = (params: EsgAnnouncementProps) =>
  request.get({
    url: Api.companyEsg,
    params
  });
/** esg公共tab信息 */
export const getClassificationCode2 = (id: string) =>
  request.get({
    url: Api.classificationCode2,
    params: {
      id,
      classificationCode: 300000,
      esgFlag: true
    }
  });

export interface EsgEvent extends PageProps {
  /** 公司 id */
  companyId?: string;
  id?: string;
  /** 排序 noticeDate:desc,tagYear:desc */
  sortRule?: string;
  /**   发行结束日期，yyyy-MM-dd，可选*/
  eventEndDate?: string;
  /** 发行起始日期，yyyy-MM-dd，可选 */
  eventStartDate?: string;
  /** 事件类型code(逗号分隔字符串)*/
  eventTypeCode?: string;
  /** 风险等级 */
  riskLevel?: string;
}

/** esg争议事件 */
export const getEsgEventF9 = (params: EsgEvent) => request.get({ url: Api.getEsgEventF9, params });

/** esg争议事件code */
export const getEsgEventCodes = (companyId) =>
  request.get({
    url: Api.esgEventCodes,
    params: { companyId }
  });

/** esg争议事件风险等级 */
export const getEsgEventRiskLevel = () =>
  request.get({
    url: Api.esgEventRiskLevel
  });

export interface CertificationProps extends PageProps {
  companyId?: string;
  sortRule?: string;
}

/** esg管理体系认证 */
export const getCertificationF9 = (params: CertificationProps) => request.get({ url: Api.getCertificationF9, params });

/** 环境处罚 */
export const getPenaltyF9 = (params: EsgEvent) => request.get({ url: Api.getPunishData, params });

export interface CarbonReduction {
  /** 碳减排领域 */
  carbonReductionTerritoryCode?: string;
  /** 公司 id */
  companyId?: string;
  /** 排序指标 */
  indicatorFiled?: string;
  /** 指标顺序（asc | desc） */
  indicatorOrder?: string;
  /** 值类型 */
  valueTypeCode?: string;
  pageNum?: number;
  pageSize?: number;
}

/** 碳减排 */
export const getCarbonReductionF9 = (params: CarbonReduction) =>
  request.get({
    url: Api.getCarbonReductionF9,
    params
  });

export interface GreenCredit {
  /** 数据归属 */
  companyType?: Numberish;
  /** 公司 id */
  companyId?: string;
  /** 是否是主要指标 */
  isKeyIndicators?: boolean;
}

/** 绿色信贷 */
export const getGreenCreditF9 = (params: GreenCredit) =>
  request.get({
    url: Api.greenCreditF9,
    params
  });

/** 是否为上市公司 */
export const getIsListedCompany = (companyId: string) =>
  request.get({
    url: Api.isListedCompany,
    params: { companyId }
  });

/** 社会治理 */
export const getSgPerformance = (params: any) =>
  request.get({
    url: Api.getSgPerformance,
    params
  });

export interface IEnvironment {
  companyId: string;
  companyType?: number;
  isKeyIndicators?: boolean;
  isBlankLine?: boolean;
}
/** 环境绩效 */
export const getEnvironmentalPerformance = (params: IEnvironment) => request.get({ url: Api.environmentalPerformanceF9, params });

/** 绿色债券 */
export interface IGreenBond {
  companyId: string;
  maturityType: number;
  pageNum?: number;
  pageSize?: number;
}
export const getGreenBondF9 = (params: IGreenBond) => request.get({ url: Api.getGreenBondF9, params });

/** 绿色债券项目 */
export interface IGreenBondProject {
  companyId: string;
  pageNum?: number;
  pageSize?: number;
}
export const getGreenBondProjectF9 = (params: IGreenBondProject) => request.get({ url: Api.getGreenProjectF9, params });


/** 监测数据 */
export const getMonitoring = (params) => request.post({ url: Api.monitoring, params });
/** 监测项目筛选 */
export const getMonitorItem = (params) => request.get({ url: Api.getMonitorItem, params });
/** 监测点筛选 */
export const getMonitorStation = (params) => request.get({ url: Api.getMonitorStation, params });
/** 未开展监测列表 */
export const getNoSelfMonitorF9n = (params) => request.get({ url: Api.noSelfMonitorF9, params });
/** 不监测类型筛选 */
export const getNoSelfMonitorType = (params) => request.get({ url: Api.noSelfMonitorType, params });
/** 不监测名称筛选 */
export const getNoSelfMonitorItem = (params) => request.get({ url: Api.noSelfMonitorItem, params });
/** 治污设施异常列表接口 */
export const getAbnormalFacilities = (params) => request.get({ url: Api.abnormalFacilities, params });
/** 治污设施异常许可证号筛选项接口 */
export const getAbnormalFacilitiesFilter = (params) => request.get({ url: Api.abnormalFacilitiesNoFilter, params });
/** 治污设施异常污染因子筛选项接口 */
export const getAbnormalFacilitiesPollutionFilter = (params) => request.get({ url: Api.abnormalFacilitiesPollutionFilter, params });
/** 超标排放取值类型获取 */
export const getSupervisoryMonitorType = (params) => request.get({ url: Api.getSupervisoryMonitorType, params });
